package xlog

import (
	"bytes"
	"runtime"
)

func extractGID(s []byte) string {
	s = s[len("goroutine "):]
	s = s[:bytes.IndexByte(s, ' ')]
	return string(s)
}

func GoroutineId() string {
	var buf [64]byte
	return extractGID(buf[:runtime.Stack(buf[:], false)])
}